// 点击添加喜欢
function add_favorite_num(id, catid, elementId) {
	$.ajax({
		 type: "GET",
                 url: baseurl+'news/?news_id='+id+'&act=favorite',
		 cache:false,
		 async:true,
		 dataType: "json",
		 success: function(data){
		     if (parseInt(data.success) == 1) {
                            $('#favorite_'+id).html(parseInt($('#favorite_'+id).html())+1);
			 }else{
			    layerdialog.showError(data.msg);
                        }
                }
	});	
}

// 点击分享
function add_share(id) {
	$.ajax({
		 type: "GET",
		 url: baseurl+'news/share.html?news_id='+id,
		 cache:false,
		 async:true,
		 dataType: "json",
		 success: function(data){
		     if (parseInt(data.status) == 1) {
                            if ($('#socialshare_'+id)){
                               $('#socialshare_'+id).html(parseInt($('#socialshare_'+id).html())+1);
                            }
			 }else{
			    layerdialog.showError(data.msg);
                         }
		 }
	});	
}

//加载更多
function loadMore(currentPage){
	$.get(baseurl+'/news/new_list.html',{page:currentPage},function(data){
		$('.LoadMore').css('display','none');
		$('#item_list_container').append(data);
		scrollOffset($(".LoadMore").offset());
	});
}

//参加活动
function add_activity(obj){
    if($(obj).attr("isguest")){
            if(window.confirm("请先登录！")){
                window.location.href =DOMAIN_MAIN+ '/passport/login/';           
            }
            return false;
        }
        var that = obj;
        var data={};
        data.activityid = $(obj).attr("activityid"); 
        data.title = $(obj).prev().attr("title");
        var li = $(that).parents("li");
        $.ajax({
            url:baseurl+'/news/activity.html',
            dataType:'json',
            data:data,
            type:'post',
            success:function(res){
               
                if(res.status=='error'){
                    layerdialog.showError(res.data);
                }else{
                     $(that).remove();
                    li.append('<span class="Act_ul_btn_2 ActJoin_btn_2">已参加</span>');
                }
            }
        });
}

//顶操作
function support(id) {
    $.get(baseurl+'/news/support.html?comment_id='+id, function(data){
        eval("var data="+data);
        if(data.status == 1) {
                $('#support_'+id).html(parseInt($('#support_'+id).html())+1);
        } else {
                layerdialog.showError(data.msg);
        }
    });
}

//踩操作
function disagree(id) {
    $.get(baseurl+'/news/disagree.html?comment_id='+id, function(data){
        eval("var data="+data);
        if(data.status == 1) {
                $('#disagree_'+id).html(parseInt($('#disagree_'+id).html())+1);
        } else {
                layerdialog.showError(data.msg);
        }
    });
}